package com.wxy;


import java.io.IOException;

import java.io.InputStream;
import java.util.logging.ConsoleHandler;

import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

import org.apache.log4j.BasicConfigurator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.wxy.service.userService;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class example {
	@Autowired
	private userService userService;
//	@Test
//	public void test1() {
//		Logger logger=Logger.getLogger("com.wxy.example");
//		logger.info(userService.findUser().toString());  
//	}
//	@Test
//	public void julLogger() throws Exception {
////		Logger logger=Logger.getLogger("com.wxy.example");
////		logger.info("日志技术");
////		logger.log(Level.INFO,"info级别");
////		System.out.println("-------------------");
////		//关闭系统默认配置
////		logger.setUseParentHandlers(false);
////		//自定义配置日志级别
////		//创建ConsoleHandler
////		ConsoleHandler consoleHandler=new ConsoleHandler();
////		//创建简单格式转换对象
////		SimpleFormatter simpleFormatter=new SimpleFormatter();
////		//进行关联
////		consoleHandler.setFormatter(simpleFormatter);
////		consoleHandler.setLevel(Level.ALL);
////		logger.addHandler(consoleHandler);
//		InputStream inputStream=example.class.getClassLoader().getResourceAsStream("logging.properties");
//		LogManager logManager=LogManager.getLogManager();
//		logManager.readConfiguration(inputStream);
//		Logger logger=Logger.getLogger("com.wxy");
//		//配置日志具体级别
//		//logger.setLevel(Level.ALL);
//		logger.severe("错误信息");
//		logger.warning("警告信息");
//		logger.info("日志输出");
//		logger.fine("fine");
//		logger.finer("finer");
//		logger.finest("finest");
//	}
	@Test
	public void Log4jLogger() {
		//BasicConfigurator.configure();
		org.apache.log4j.Logger logger=org.apache.log4j.Logger.getLogger("com.wxy.example");
			logger.fatal("fatal信息,危险信息!!!");
			logger.error("错误信息!!!");
			logger.warn("warn警告信息");
			logger.info("info普通信息");
			logger.debug("debug调试信息");
			logger.trace("trace信息");
			String nameString="zhangsan";
			logger.info("info信息"+nameString);
	}
}
